AtacR

Normalication

Using GoF(Goodness of fit)

Differential expression

Mutants_Treatments vs Wildtype_Untreated

Read Dataset

Use AtacR package.
Set gene regions as windows.

library(atacr)
library(magrittr)
library(UpSetR)
library(SummarizedExperiment)
## Loading required package: GenomicRanges
## Loading required package: stats4
## Loading required package: BiocGenerics
## Loading required package: parallel
## 
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:parallel':
## 
##     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
##     clusterExport, clusterMap, parApply, parCapply, parLapply,
##     parLapplyLB, parRapply, parSapply, parSapplyLB
## The following objects are masked from 'package:stats':
## 
##     IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
## 
##     anyDuplicated, append, as.data.frame, basename, cbind,
##     colMeans, colnames, colSums, dirname, do.call, duplicated,
##     eval, evalq, Filter, Find, get, grep, grepl, intersect,
##     is.unsorted, lapply, lengths, Map, mapply, match, mget, order,
##     paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind,
##     Reduce, rowMeans, rownames, rowSums, sapply, setdiff, sort,
##     table, tapply, union, unique, unsplit, which, which.max,
##     which.min
## Loading required package: S4Vectors
## 
## Attaching package: 'S4Vectors'
## The following object is masked from 'package:base':
## 
##     expand.grid
## Loading required package: IRanges
## Loading required package: GenomeInfoDb
## Loading required package: Biobase
## Welcome to Bioconductor
## 
##     Vignettes contain introductory material; view with
##     'browseVignettes()'. To cite Bioconductor, see
##     'citation("Biobase")', and for packages 'citation("pkgname")'.
## Loading required package: DelayedArray
## Loading required package: matrixStats
## 
## Attaching package: 'matrixStats'
## The following objects are masked from 'package:Biobase':
## 
##     anyMissing, rowMedians
## Loading required package: BiocParallel
## 
## Attaching package: 'DelayedArray'
## The following objects are masked from 'package:matrixStats':
## 
##     colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges
## The following objects are masked from 'package:base':
## 
##     aperm, apply
# When use this script first time, we use make_counts method in AtacR package.
# After second time, we can use .rds files.
# test_AtacR_desc_final.csv, gene_symbol_region.gff made by XXXXX.py

if (file.exists("../data/rna_seq_count_data.rds") ){
    data <- readRDS("../data/rna_seq_count_data.rds")
} else {
    my_params = make_params(
        paired_map = FALSE, 
        minq = 30, 
        dedup = TRUE
      )

    data <-  make_counts('../data/gene_symbol_region.gff',
            '../data/AtacR_desc.csv',
            is_rnaseq = TRUE,
            filter_params = my_params
          )
}

Save all dataset (.rds)

Save read counts data (.csv)

Fix some data

read counts in AT1G65483_wt_un_r1~3 = 0.
We modified AT1G65483_wt_un_r1 = 1 to calculate differential expression.

write.csv(assays(data$bait_windows)[[1]], file="../outputs/rna_seq_count_in_mRNA.csv")
saveRDS(data, file="../outputs/rna_seq_count_data.rds")
assays(data$bait_windows)[[1]]["AT1G65483","wt_un_r1"] <- 1

Summary

summary(data)
## ATAC-seq experiment of 34 treatments in 102 samples
##  Treatments: eds1_a2,eds1_a4,eds1_kv,eds1_mk,gdna,gh_a2,gh_a4,gh_kv,gh_mk,myc234_a2,myc234_a4,myc234_kv,myc234_mk,peds_a2,peds_a4,peds_kv,peds_mk,r1ab_a2,r1ab_a4,r1ab_kv,r1ab_mk,sid2_a2,sid2_a4,sid2_kv,sid2_mk,tplr14_a2,tplr14_a4,tplr14_kv,tplr14_mk,wt_a2,wt_a4,wt_kv,wt_mk,wt_un 
##  Samples: eds1_a2_r1,eds1_a2_r2,eds1_a2_r3,eds1_a4_r1,eds1_a4_r2,eds1_a4_r3,eds1_kv_r1,eds1_kv_r2,eds1_kv_r3,eds1_mk_r1,eds1_mk_r2,eds1_mk_r3,gdna_r1,gdna_r2,gdna_r3,gh_a2_r1,gh_a2_r2,gh_a2_r3,gh_a4_r1,gh_a4_r2,gh_a4_r3,gh_kv_r1,gh_kv_r2,gh_kv_r3,gh_mk_r1,gh_mk_r2,gh_mk_r3,myc234_a2_r1,myc234_a2_r2,myc234_a2_r3,myc234_a4_r1,myc234_a4_r2,myc234_a4_r3,myc234_kv_r1,myc234_kv_r2,myc234_kv_r3,myc234_mk_r1,myc234_mk_r2,myc234_mk_r3,peds_a2_r1,peds_a2_r2,peds_a2_r3,peds_a4_r1,peds_a4_r2,peds_a4_r3,peds_kv_r1,peds_kv_r2,peds_kv_r3,peds_mk_r1,peds_mk_r2,peds_mk_r3,r1ab_a2_r1,r1ab_a2_r2,r1ab_a2_r3,r1ab_a4_r1,r1ab_a4_r2,r1ab_a4_r3,r1ab_kv_r1,r1ab_kv_r2,r1ab_kv_r3,r1ab_mk_r1,r1ab_mk_r2,r1ab_mk_r3,sid2_a2_r1,sid2_a2_r2,sid2_a2_r3,sid2_a4_r1,sid2_a4_r2,sid2_a4_r3,sid2_kv_r1,sid2_kv_r2,sid2_kv_r3,sid2_mk_r1,sid2_mk_r2,sid2_mk_r3,tplr14_a2_r1,tplr14_a2_r2,tplr14_a2_r3,tplr14_a4_r1,tplr14_a4_r2,tplr14_a4_r3,tplr14_kv_r1,tplr14_kv_r2,tplr14_kv_r3,tplr14_mk_r1,tplr14_mk_r2,tplr14_mk_r3,wt_a2_r1,wt_a2_r2,wt_a2_r3,wt_a4_r1,wt_a4_r2,wt_a4_r3,wt_kv_r1,wt_kv_r2,wt_kv_r3,wt_mk_r1,wt_mk_r2,wt_mk_r3,wt_un_r1,wt_un_r2,wt_un_r3 
##  Bait regions used: 52 
##  Total Windows: 104 
##  
##  On/Off target read counts:
##            sample off_target on_target percent_on_target
## 1     eds1_a2_r1     535272   6813408          92.71608
## 2     eds1_a2_r2     866734   4516921          83.90064
## 3     eds1_a2_r3     600574   4253966          87.62861
## 4     eds1_a4_r1     669760   2949519          81.49466
## 5     eds1_a4_r2    1046612   4034113          79.40034
## 6     eds1_a4_r3     718131   3460738          82.81518
## 7     eds1_kv_r1     466351   2524127          84.40547
## 8     eds1_kv_r2     713463   2998005          80.77680
## 9     eds1_kv_r3     394773   2242144          85.02899
## 10    eds1_mk_r1     344486   1294368          78.98007
## 11    eds1_mk_r2     653586   1310516          66.72342
## 12    eds1_mk_r3     416530   1028606          71.17711
## 13       gdna_r1      13402      6760          33.52842
## 14       gdna_r2      11575      6131          34.62668
## 15       gdna_r3      11497      5567          32.62424
## 16      gh_a2_r1     470469   2917555          86.11376
## 17      gh_a2_r2     297422   1490610          83.36596
## 18      gh_a2_r3     610761   3271003          84.26589
## 19      gh_a4_r1     661336   4029737          85.90224
## 20      gh_a4_r2     168012    837371          83.28876
## 21      gh_a4_r3     661863   3299518          83.29211
## 22      gh_kv_r1     854857   4545999          84.17182
## 23      gh_kv_r2     566501   3448229          85.88944
## 24      gh_kv_r3     516607   2864966          84.72288
## 25      gh_mk_r1    1476438   3878330          72.42760
## 26      gh_mk_r2     522528   1018137          66.08426
## 27      gh_mk_r3     473263   1849173          79.62213
## 28  myc234_a2_r1     891659   9019312          91.00331
## 29  myc234_a2_r2    1040718   7128121          87.25990
## 30  myc234_a2_r3     684428   6144520          89.97755
## 31  myc234_a4_r1     758354   7354204          90.65210
## 32  myc234_a4_r2     831423   7254296          89.71739
## 33  myc234_a4_r3     657413   7346057          91.78590
## 34  myc234_kv_r1     873898   7974571          90.12374
## 35  myc234_kv_r2     678928   4078510          85.72913
## 36  myc234_kv_r3     532061   5448421          91.10338
## 37  myc234_mk_r1     369879   1539403          80.62732
## 38  myc234_mk_r2     551731   1624700          74.64974
## 39  myc234_mk_r3     417546   1524779          78.50277
## 40    peds_a2_r1     591875   3321091          84.87401
## 41    peds_a2_r2     250049   1035827          80.55419
## 42    peds_a2_r3     675164   4637311          87.29097
## 43    peds_a4_r1     557807   3161051          85.00058
## 44    peds_a4_r2      13071     94154          87.80975
## 45    peds_a4_r3     904446   9411858          91.23285
## 46    peds_kv_r1     377514   1201677          76.09447
## 47    peds_kv_r2     214757    710449          76.78820
## 48    peds_kv_r3     638846   5678061          89.88673
## 49    peds_mk_r1     543897    703042          56.38143
## 50    peds_mk_r2     105051    122944          53.92399
## 51    peds_mk_r3    1010932   5345638          84.09627
## 52    r1ab_a2_r1     740094   8950078          92.36243
## 53    r1ab_a2_r2     617984   5115989          89.22241
## 54    r1ab_a2_r3     669800   5914292          89.82700
## 55    r1ab_a4_r1     946963  13205740          93.30896
## 56    r1ab_a4_r2     302827   2630425          89.67607
## 57    r1ab_a4_r3     621682   6120986          90.77988
## 58    r1ab_kv_r1    1725748  23677372          93.20655
## 59    r1ab_kv_r2     368466   3395624          90.21102
## 60    r1ab_kv_r3     653248   7297218          91.78353
## 61    r1ab_mk_r1    1760853  16448880          90.33015
## 62    r1ab_mk_r2     230443    565217          71.03750
## 63    r1ab_mk_r3     456801   2996391          86.77163
## 64    sid2_a2_r1    1026895   7012396          87.22655
## 65    sid2_a2_r2     149090    909752          85.91952
## 66    sid2_a2_r3     561296   3758063          87.00511
## 67    sid2_a4_r1    1319090  12404840          90.38839
## 68    sid2_a4_r2     388071   3363746          89.65645
## 69    sid2_a4_r3     613855   5050928          89.16366
## 70    sid2_kv_r1     741646   4826886          86.68148
## 71    sid2_kv_r2     270848   1585434          85.40911
## 72    sid2_kv_r3     535664   3214101          85.71473
## 73    sid2_mk_r1     897334   3244768          78.33627
## 74    sid2_mk_r2     241621    537169          68.97482
## 75    sid2_mk_r3     515073   2869223          84.78050
## 76  tplr14_a2_r1     577338   5078470          89.79212
## 77  tplr14_a2_r2     273345   2101935          88.49209
## 78  tplr14_a2_r3     457328   3495833          88.43133
## 79  tplr14_a4_r1     428528   4754136          91.73151
## 80  tplr14_a4_r2     250498   2532460          90.99886
## 81  tplr14_a4_r3     530529   4702373          89.86167
## 82  tplr14_kv_r1     631357   5575859          89.82866
## 83  tplr14_kv_r2     409717   3005163          88.00201
## 84  tplr14_kv_r3     361573   2728562          88.29912
## 85  tplr14_mk_r1     744305   3192639          81.09435
## 86  tplr14_mk_r2     215068    470466          68.62767
## 87  tplr14_mk_r3     465019   1744543          78.95425
## 88      wt_a2_r1     969966  10456691          91.51138
## 89      wt_a2_r2     466516   3820573          89.11812
## 90      wt_a2_r3     883420   7809293          89.83723
## 91      wt_a4_r1    1081963  14550301          93.07865
## 92      wt_a4_r2     616462   6609402          91.46867
## 93      wt_a4_r3     803346   9509319          92.21010
## 94      wt_kv_r1     872784   9129107          91.27381
## 95      wt_kv_r2    1864114  15055972          88.98283
## 96      wt_kv_r3     733621   8551487          92.09895
## 97      wt_mk_r1     522204   4827155          90.23801
## 98      wt_mk_r2     114902    475252          80.53017
## 99      wt_mk_r3     405915   3209662          88.77316
## 100     wt_un_r1     661253   1050531          61.37054
## 101     wt_un_r2     543072    928314          63.09113
## 102     wt_un_r3     474208    852907          64.26775 
##  Quantiles: 
##  $bait_windows
##     eds1_a2_r1 eds1_a2_r2 eds1_a2_r3 eds1_a4_r1 eds1_a4_r2 eds1_a4_r3
## 1%         0.0       0.51      15.81       0.00       9.69       0.51
## 5%       105.3      52.95     138.35      82.05      89.85      36.60
## 95%   612209.6  305203.15  297397.85  179818.85  219240.25  215957.70
## 99%   843114.7  854820.71  729309.44  555801.17  899143.25  731027.56
##     eds1_kv_r1 eds1_kv_r2 eds1_kv_r3 eds1_mk_r1 eds1_mk_r2 eds1_mk_r3
## 1%       37.23        0.0      15.30       0.00       0.00       0.00
## 5%      126.85        9.9      47.75       3.75       2.00       0.00
## 95%  144710.50   142104.9  138194.90   61212.70   72885.75   68214.05
## 99%  563908.65   827999.9  545970.66  474976.48  501729.18  397104.31
##     gdna_r1 gdna_r2 gdna_r3  gh_a2_r1 gh_a2_r2 gh_a2_r3  gh_a4_r1
## 1%    15.02    7.55   14.57      0.00      0.0      0.0     13.26
## 5%    20.85   14.55   18.55     36.05      7.3     31.1    126.95
## 95%  359.65  325.00  315.90 252713.40  89983.6 316417.9 330185.15
## 99%  492.92  512.63  383.75 476478.52 395308.5 653637.2 720620.90
##      gh_a4_r2  gh_a4_r3  gh_kv_r1   gh_kv_r2 gh_kv_r3   gh_mk_r1  gh_mk_r2
## 1%       0.00      0.51     12.75       3.57      0.0       0.51      0.00
## 5%       1.65      5.40     76.60      19.25      2.2      29.50      0.55
## 95%  41158.90 267568.00 509199.00  148366.70 294364.1  210106.80  39511.40
## 99% 210801.13 614184.02 797749.89 1059589.95 712977.5 1316424.96 361246.80
##      gh_mk_r3 myc234_a2_r1 myc234_a2_r2 myc234_a2_r3 myc234_a4_r1
## 1%       0.00         0.00         8.16        47.03        63.75
## 5%       8.80       534.55       240.60       169.80       453.05
## 95%  76761.95    581865.30    519314.25    534043.25    550122.35
## 99% 718017.54    689453.12    968558.15    743397.39    685801.72
##     myc234_a4_r2 myc234_a4_r3 myc234_kv_r1 myc234_kv_r2 myc234_kv_r3
## 1%          3.57        54.98       110.67         9.69        53.04
## 5%        294.85       298.60       660.55        58.65       143.20
## 95%    559558.55    720508.40    576098.45    248381.30    463115.55
## 99%    897005.56    930991.19   1000539.43    655530.75    794828.27
##     myc234_mk_r1 myc234_mk_r2 myc234_mk_r3 peds_a2_r1 peds_a2_r2
## 1%         36.72         8.16         4.08       0.00       0.00
## 5%         84.40        38.60       103.15      50.85       6.60
## 95%    121817.95    126012.25     98873.10  216700.45   69010.15
## 99%    240896.10    193050.41    254003.44  707553.43  195668.66
##     peds_a2_r3 peds_a4_r1 peds_a4_r2 peds_a4_r3 peds_kv_r1 peds_kv_r2
## 1%       45.90        0.0       0.00      26.52        0.0        0.0
## 5%      260.35       55.5       1.10     480.65       10.9        0.0
## 95%  315010.05   257966.0    7283.35  762021.80    84154.6    46584.5
## 99%  682274.99   418957.6   13839.57 1164510.93   298147.0   180324.2
##     peds_kv_r3 peds_mk_r1 peds_mk_r2 peds_mk_r3 r1ab_a2_r1 r1ab_a2_r2
## 1%       77.01        0.0       0.51     130.56      26.52        0.0
## 5%      355.50        2.1       1.00     519.20     160.30       38.0
## 95%  443150.30    66865.8    6742.35  353323.65  667024.60   376864.5
## 99%  869471.12   178263.2   43415.26  880920.25  785596.47   808616.2
##     r1ab_a2_r3 r1ab_a4_r1 r1ab_a4_r2 r1ab_a4_r3 r1ab_kv_r1 r1ab_kv_r2
## 1%       42.13      77.52      18.87      74.24      19.38       0.00
## 5%      197.20     171.55      86.40     159.95     138.60      48.95
## 95%  396556.45 1097876.45  198774.65  520283.40 1859368.45  258776.60
## 99%  862334.44 1459497.72  292363.30  795467.78 2982785.93  577330.66
##     r1ab_kv_r3 r1ab_mk_r1 r1ab_mk_r2 r1ab_mk_r3 sid2_a2_r1 sid2_a2_r2
## 1%       42.33      62.73       3.06       5.10      18.36       2.04
## 5%      178.85     693.85       8.75      91.70      65.05       7.75
## 95%  642748.85 1626059.75   29827.40   99988.35  589915.80   63502.10
## 99% 1009939.63 3674497.75  152201.88 1125561.02 1040531.25  152777.70
##     sid2_a2_r3 sid2_a4_r1 sid2_a4_r2 sid2_a4_r3 sid2_kv_r1 sid2_kv_r2
## 1%       12.24      24.99       87.7       1.53      26.01      11.65
## 5%      180.20     314.90      149.2     104.80     383.10     100.15
## 95%  302038.75 1187459.85   214217.6  500594.05  448638.15   98259.35
## 99%  657585.18 1776684.49   405487.2  702533.52  591645.58  275376.20
##     sid2_kv_r3 sid2_mk_r1 sid2_mk_r2 sid2_mk_r3 tplr14_a2_r1 tplr14_a2_r2
## 1%        5.61       6.12        5.1       0.51         1.53          0.0
## 5%       39.30      83.75       32.5      68.45        93.00         26.2
## 95%  302743.70  218186.30    40361.5  110537.25    409228.95     168623.2
## 99%  717274.56 1012627.36   149245.2  986438.43    629053.84     261479.0
##     tplr14_a2_r3 tplr14_a4_r1 tplr14_a4_r2 tplr14_a4_r3 tplr14_kv_r1
## 1%         16.32         5.61          0.0        19.38        19.12
## 5%         63.90       167.30          9.2       101.65       165.95
## 95%    295536.45    407674.70     204904.3    446603.15    447551.00
## 99%    511838.68    557252.34     322617.4    552011.88    701260.75
##     tplr14_kv_r2 tplr14_kv_r3 tplr14_mk_r1 tplr14_mk_r2 tplr14_mk_r3
## 1%          1.02         4.59         3.06         0.00          0.0
## 5%         56.30        29.55        83.00         6.20         10.4
## 95%    191000.20    248468.45    180164.50     36203.85      78385.3
## 99%    422717.77    490080.11    951944.90     90826.81     595843.1
##       wt_a2_r1  wt_a2_r2   wt_a2_r3   wt_a4_r1  wt_a4_r2   wt_a4_r3
## 1%       57.63      0.00      30.60      24.48      8.67       6.12
## 5%      192.20     64.05     184.85     173.35     88.70     301.95
## 95%  834809.40 284033.80  570219.05 1117991.45 526551.65  765873.65
## 99% 1580525.86 533019.13 1340331.73 1623420.93 770767.31 1161230.66
##      wt_kv_r1   wt_kv_r2  wt_kv_r3   wt_mk_r1 wt_mk_r2   wt_mk_r3 wt_un_r1
## 1%        0.0      12.14       0.0       6.63     0.00      22.95      0.0
## 5%       79.2     185.10     218.6      99.20    23.10     109.65      0.0
## 95%  762052.9  860718.10  781883.7  244969.30 43908.95  116827.40 122538.8
## 99% 1472739.3 2590975.58 1199536.8 1436644.37 75654.47 1123431.46 277569.6
##      wt_un_r2  wt_un_r3
## 1%       0.00      0.00
## 5%       1.00      6.60
## 95%  90682.75  80633.15
## 99% 276634.10 221397.79
## 
## $non_bait_windows
##     eds1_a2_r1 eds1_a2_r2 eds1_a2_r3 eds1_a4_r1 eds1_a4_r2 eds1_a4_r3
## 1%       75.85     181.91      84.09     128.46     174.82      90.78
## 5%      337.15     347.50     172.90     300.85     353.45     215.50
## 95%   39479.55   73094.45   60014.50   50001.05   74830.20   41980.25
## 99%  149848.60  261214.55  173619.72  218259.91  352583.38  250958.39
##     eds1_kv_r1 eds1_kv_r2 eds1_kv_r3 eds1_mk_r1 eds1_mk_r2 eds1_mk_r3
## 1%       69.63     123.53      42.84        5.1       4.08       10.2
## 5%      178.10     249.90     128.10       64.1      67.40       52.9
## 95%   26956.60   28235.95   18229.85    14884.6   28204.20    32123.3
## 99%  157170.17  258094.65  138334.47   128765.4  257575.68   144656.9
##     gdna_r1 gdna_r2 gdna_r3  gh_a2_r1 gh_a2_r2  gh_a2_r3  gh_a4_r1
## 1%    40.57   28.81   37.53     85.52    37.17    135.89     97.14
## 5%    50.95   47.75   49.10    200.65   103.50    186.55    205.50
## 95%  553.90  441.45  442.80  48130.10 24253.70  57085.25  64721.55
## 99%  632.16  560.00  556.93 123907.60 89917.67 179554.02 191573.82
##     gh_a4_r2  gh_a4_r3 gh_kv_r1  gh_kv_r2  gh_kv_r3  gh_mk_r1  gh_mk_r2
## 1%     24.46    114.96    138.5     38.68     31.56     47.43     11.22
## 5%    111.00    213.60    262.2    156.95    124.30    224.65     68.75
## 95% 12126.75  60879.20  57253.2  48793.50  34784.15  78954.35  19462.75
## 99% 53081.10 191924.22 266905.1 166045.63 165205.31 560490.45 208251.29
##      gh_mk_r3 myc234_a2_r1 myc234_a2_r2 myc234_a2_r3 myc234_a4_r1
## 1%       9.69       221.22       152.99        64.26       161.26
## 5%      84.70       410.95       373.45       220.15       260.15
## 95%  24383.50     59474.05     56964.30     52786.20     49169.60
## 99% 179575.36    193820.77    371400.64    210174.75    208288.86
##     myc234_a4_r2 myc234_a4_r3 myc234_kv_r1 myc234_kv_r2 myc234_kv_r3
## 1%          94.1        59.33        98.93        72.64         61.0
## 5%         229.9       239.35       247.10       266.80        202.0
## 95%      55380.7     45738.60     68158.05     55318.90      48217.7
## 99%     270624.3    202089.23    271456.78    226746.18     154632.0
##     myc234_mk_r1 myc234_mk_r2 myc234_mk_r3 peds_a2_r1 peds_a2_r2
## 1%         21.38        66.57        29.58     103.39      30.03
## 5%        141.75       165.20       125.25     271.35      97.00
## 95%     22500.40     19024.20     19373.70   50324.75   25081.70
## 99%    129510.60    217195.14    160125.26  161616.26   66202.89
##     peds_a2_r3 peds_a4_r1 peds_a4_r2 peds_a4_r3 peds_kv_r1 peds_kv_r2
## 1%       79.52     136.23       2.02     105.78      46.29      33.11
## 5%      208.60     247.05       4.00     312.75     117.50      76.30
## 95%   64728.70   49427.60    1014.25   76708.55   21541.35   18431.55
## 99%  198295.83  139198.63    3022.12  268566.93  123756.65   63543.43
##     peds_kv_r3 peds_mk_r1 peds_mk_r2 peds_mk_r3 r1ab_a2_r1 r1ab_a2_r2
## 1%       67.49      23.32       0.51       92.6     190.62     165.85
## 5%      221.20      71.70      15.30      289.9     375.95     358.05
## 95%   60105.95   44996.30    9410.70    42510.3   59803.60   47453.15
## 99%  183088.60  176518.26   32207.49   380197.6  178574.07  183014.99
##     r1ab_a2_r3 r1ab_a4_r1 r1ab_a4_r2 r1ab_a4_r3 r1ab_kv_r1 r1ab_kv_r2
## 1%       76.10      92.63      39.56      73.74      285.8      39.25
## 5%      280.25     298.15     152.20     283.60      459.4     117.85
## 95%   56361.75   83352.85   25743.40   50921.75   153756.4   31681.20
## 99%  191934.06  263121.93   75008.68  180846.07   468283.6  107277.38
##     r1ab_kv_r3 r1ab_mk_r1 r1ab_mk_r2 r1ab_mk_r3 sid2_a2_r1 sid2_a2_r2
## 1%       98.37     143.31       5.10      12.75     256.85      25.38
## 5%      275.35     735.35      39.40      59.20     478.10      72.55
## 95%   52871.85   79122.15    6821.00   23144.65   91130.95   12090.75
## 99%  187646.94  591357.94   94211.53  173121.68  268720.74   44991.93
##     sid2_a2_r3 sid2_a4_r1 sid2_a4_r2 sid2_a4_r3 sid2_kv_r1 sid2_kv_r2
## 1%       53.37     219.95     209.30     128.65     123.51      63.65
## 5%      206.90     457.80     439.25     266.30     333.30     124.30
## 95%   56733.05   93996.75   24915.35   49737.55   70008.80   26199.65
## 99%  155619.58  340740.47   71256.45  179502.84  191287.62   70910.84
##     sid2_kv_r3 sid2_mk_r1 sid2_mk_r2 sid2_mk_r3 tplr14_a2_r1 tplr14_a2_r2
## 1%       79.56      38.76       8.67      27.54        79.79        28.01
## 5%      181.65     149.40      39.70      88.65       265.60       144.50
## 95%   36439.95   44125.85   19466.60   22015.90     55944.05     26437.05
## 99%  173851.97  325579.26   80120.00  199122.10    156580.91     75442.43
##     tplr14_a2_r3 tplr14_a4_r1 tplr14_a4_r2 tplr14_a4_r3 tplr14_kv_r1
## 1%         49.25        58.86        29.42         51.6       117.61
## 5%        159.20       256.60       108.00        206.7       279.20
## 95%     42558.05     32936.10     19007.45      43935.7     51560.20
## 99%    137846.52    124453.23     74196.67     163542.8    181462.32
##     tplr14_kv_r2 tplr14_kv_r3 tplr14_mk_r1 tplr14_mk_r2 tplr14_mk_r3
## 1%         69.85        48.33        14.79         3.06        12.75
## 5%        190.85       106.50       167.20        27.20        70.30
## 95%     40841.55     31829.30     34915.20     13872.90     25991.40
## 99%    114441.28    112382.64    276270.40     76213.89    176416.70
##      wt_a2_r1  wt_a2_r2  wt_a2_r3  wt_a4_r1  wt_a4_r2 wt_a4_r3  wt_kv_r1
## 1%     117.22     58.47    107.13    118.45    163.37    132.2    105.56
## 5%     347.10    189.40    321.75    343.85    301.20    400.1    239.30
## 95%  68184.00  33684.90  79445.90  72291.80  35956.25  64972.5  71698.90
## 99% 289922.49 144295.74 257789.31 337102.91 175661.17 229800.5 268936.49
##      wt_kv_r2 wt_kv_r3  wt_mk_r1 wt_mk_r2  wt_mk_r3  wt_un_r1  wt_un_r2
## 1%     353.69    128.0     62.22     7.14     16.83     24.99      9.69
## 5%     693.50    371.2    188.65    48.10     93.55    111.00     86.90
## 95% 143775.20  62650.2  17918.70  9963.85  19159.60  53308.75  37782.40
## 99% 556533.90 201247.9 188269.80 31638.09 149831.81 216565.37 188065.44
##      wt_un_r3
## 1%      29.58
## 5%      98.30
## 95%  40999.60
## 99% 154483.15
##  
##  Read depths:
##            sample off_target   on_target
## 1     eds1_a2_r1 10293.6923 131027.0769
## 2     eds1_a2_r2 16667.9615  86863.8654
## 3     eds1_a2_r3 11549.5000  81807.0385
## 4     eds1_a4_r1 12880.0000  56721.5192
## 5     eds1_a4_r2 20127.1538  77579.0962
## 6     eds1_a4_r3 13810.2115  66552.6538
## 7     eds1_kv_r1  8968.2885  48540.9038
## 8     eds1_kv_r2 13720.4423  57653.9423
## 9     eds1_kv_r3  7591.7885  43118.1538
## 10    eds1_mk_r1  6624.7308  24891.6923
## 11    eds1_mk_r2 12568.9615  25202.2308
## 12    eds1_mk_r3  8010.1923  19780.8846
## 13       gdna_r1   257.7308    130.0000
## 14       gdna_r2   222.5962    117.9038
## 15       gdna_r3   221.0962    107.0577
## 16      gh_a2_r1  9047.4808  56106.8269
## 17      gh_a2_r2  5719.6538  28665.5769
## 18      gh_a2_r3 11745.4038  62903.9038
## 19      gh_a4_r1 12718.0000  77494.9423
## 20      gh_a4_r2  3231.0000  16103.2885
## 21      gh_a4_r3 12728.1346  63452.2692
## 22      gh_kv_r1 16439.5577  87423.0577
## 23      gh_kv_r2 10894.2500  66312.0962
## 24      gh_kv_r3  9934.7500  55095.5000
## 25      gh_mk_r1 28393.0385  74583.2692
## 26      gh_mk_r2 10048.6154  19579.5577
## 27      gh_mk_r3  9101.2115  35561.0192
## 28  myc234_a2_r1 17147.2885 173448.3077
## 29  myc234_a2_r2 20013.8077 137079.2500
## 30  myc234_a2_r3 13162.0769 118163.8462
## 31  myc234_a4_r1 14583.7308 141427.0000
## 32  myc234_a4_r2 15988.9038 139505.6923
## 33  myc234_a4_r3 12642.5577 141270.3269
## 34  myc234_kv_r1 16805.7308 153357.1346
## 35  myc234_kv_r2 13056.3077  78432.8846
## 36  myc234_kv_r3 10231.9423 104777.3269
## 37  myc234_mk_r1  7113.0577  29603.9038
## 38  myc234_mk_r2 10610.2115  31244.2308
## 39  myc234_mk_r3  8029.7308  29322.6731
## 40    peds_a2_r1 11382.2115  63867.1346
## 41    peds_a2_r2  4808.6346  19919.7500
## 42    peds_a2_r3 12983.9231  89179.0577
## 43    peds_a4_r1 10727.0577  60789.4423
## 44    peds_a4_r2   251.3654   1810.6538
## 45    peds_a4_r3 17393.1923 180997.2692
## 46    peds_kv_r1  7259.8846  23109.1731
## 47    peds_kv_r2  4129.9423  13662.4808
## 48    peds_kv_r3 12285.5000 109193.4808
## 49    peds_mk_r1 10459.5577  13520.0385
## 50    peds_mk_r2  2020.2115   2364.3077
## 51    peds_mk_r3 19441.0000 102800.7308
## 52    r1ab_a2_r1 14232.5769 172116.8846
## 53    r1ab_a2_r2 11884.3077  98384.4038
## 54    r1ab_a2_r3 12880.7692 113736.3846
## 55    r1ab_a4_r1 18210.8269 253956.5385
## 56    r1ab_a4_r2  5823.5962  50585.0962
## 57    r1ab_a4_r3 11955.4231 117711.2692
## 58    r1ab_kv_r1 33187.4615 455334.0769
## 59    r1ab_kv_r2  7085.8846  65300.4615
## 60    r1ab_kv_r3 12562.4615 140331.1154
## 61    r1ab_mk_r1 33862.5577 316324.6154
## 62    r1ab_mk_r2  4431.5962  10869.5577
## 63    r1ab_mk_r3  8784.6346  57622.9038
## 64    sid2_a2_r1 19747.9808 134853.7692
## 65    sid2_a2_r2  2867.1154  17495.2308
## 66    sid2_a2_r3 10794.1538  72270.4423
## 67    sid2_a4_r1 25367.1154 238554.6154
## 68    sid2_a4_r2  7462.9038  64687.4231
## 69    sid2_a4_r3 11804.9038  97133.2308
## 70    sid2_kv_r1 14262.4231  92824.7308
## 71    sid2_kv_r2  5208.6154  30489.1154
## 72    sid2_kv_r3 10301.2308  61809.6346
## 73    sid2_mk_r1 17256.4231  62399.3846
## 74    sid2_mk_r2  4646.5577  10330.1731
## 75    sid2_mk_r3  9905.2500  55177.3654
## 76  tplr14_a2_r1 11102.6538  97662.8846
## 77  tplr14_a2_r2  5256.6346  40421.8269
## 78  tplr14_a2_r3  8794.7692  67227.5577
## 79  tplr14_a4_r1  8240.9231  91425.6923
## 80  tplr14_a4_r2  4817.2692  48701.1538
## 81  tplr14_a4_r3 10202.4808  90430.2500
## 82  tplr14_kv_r1 12141.4808 107228.0577
## 83  tplr14_kv_r2  7879.1731  57791.5962
## 84  tplr14_kv_r3  6953.3269  52472.3462
## 85  tplr14_mk_r1 14313.5577  61396.9038
## 86  tplr14_mk_r2  4135.9231   9047.4231
## 87  tplr14_mk_r3  8942.6731  33548.9038
## 88      wt_a2_r1 18653.1923 201090.2115
## 89      wt_a2_r2  8971.4615  73472.5577
## 90      wt_a2_r3 16988.8462 150178.7115
## 91      wt_a4_r1 20806.9808 279813.4808
## 92      wt_a4_r2 11855.0385 127103.8846
## 93      wt_a4_r3 15448.9615 182871.5192
## 94      wt_kv_r1 16784.3077 175559.7500
## 95      wt_kv_r2 35848.3462 289537.9231
## 96      wt_kv_r3 14108.0962 164451.6731
## 97      wt_mk_r1 10042.3846  92829.9038
## 98      wt_mk_r2  2209.6538   9139.4615
## 99      wt_mk_r3  7806.0577  61724.2692
## 100     wt_un_r1 12716.4038  20202.5192
## 101     wt_un_r2 10443.6923  17852.1923
## 102     wt_un_r3  9119.3846  16402.0577

Coverage_summary

It shows warning message because we mistook to treat AT4G28410 → AT4G28420

coverage_summary(data)
## Warning: Expected 4 pieces. Missing pieces filled with `NA` in 10608
## rows [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
## 20, ...].
## Warning in as.data.frame.atacr(data): 強制変換により NA が生成されました
## Picking joint bandwidth of 0.391
## Picking joint bandwidth of 0.251

Correlation between replicate plot

sample_correlation_plot(data)

detect control genes based on Goodness of fit

auto_controls <- find_controls_by_GoF(data, which = "bait_windows")
auto_controls
##  [1] "AT1G01680_PUB54"    "AT1G07160_AP2C2"    "AT1G07920"         
##  [4] "AT1G19250_FMO1"     "AT1G32640_MYC2"     "AT1G43910"         
##  [7] "AT1G51920"          "AT1G53625"          "AT1G73805_SARD1"   
## [10] "AT1G77120_ADH1"     "AT2G04450_NUDT6"    "AT2G17740_VLG"     
## [13] "AT2G45760_BAP2"     "AT3G13100_MRP7"     "AT3G13610_F6'H1"   
## [16] "AT3G26830_PAD3"     "AT3G52430_PAD4"     "AT4G05320_UBQ10"   
## [19] "AT4G18960_AG"       "AT4G21840_MSRB8"    "AT4G39030_EDS5"    
## [22] "AT5G26690_HIPP02"   "AT5G39670_CML46"    "AT5G42380_CML37"   
## [25] "AT5G44420_PDF1.2A"  "AT5G55450_nsLTP4.4"

Control genes (Not ERGs)

pre_hoc_controls <- strsplit("AT1G07160_AP2C2,AT1G07920,AT1G32640_MYC2,AT1G51920,AT1G59860_HSP17.6A-CI,AT1G77120_ADH1,AT2G17740_VLG,AT2G19190_FRK1,AT3G27850_RPL12-C,AT3G45140_LOX2,AT4G01250_WRKY22,AT4G05320_UBQ10,AT4G18960_AG,AT4G28410_RSA1,AT5G03840_TFL1,AT5G09810_ACT7,AT5G44420_PDF1.2A", ",")[[1]]
pre_hoc_controls
##  [1] "AT1G07160_AP2C2"       "AT1G07920"            
##  [3] "AT1G32640_MYC2"        "AT1G51920"            
##  [5] "AT1G59860_HSP17.6A-CI" "AT1G77120_ADH1"       
##  [7] "AT2G17740_VLG"         "AT2G19190_FRK1"       
##  [9] "AT3G27850_RPL12-C"     "AT3G45140_LOX2"       
## [11] "AT4G01250_WRKY22"      "AT4G05320_UBQ10"      
## [13] "AT4G18960_AG"          "AT4G28410_RSA1"       
## [15] "AT5G03840_TFL1"        "AT5G09810_ACT7"       
## [17] "AT5G44420_PDF1.2A"

Control genes (Not ERGs & detected by GoF)

intersect(auto_controls, pre_hoc_controls)
## [1] "AT1G07160_AP2C2"   "AT1G07920"         "AT1G32640_MYC2"   
## [4] "AT1G51920"         "AT1G77120_ADH1"    "AT2G17740_VLG"    
## [7] "AT4G05320_UBQ10"   "AT4G18960_AG"      "AT5G44420_PDF1.2A"

Plot Goodness of fit

plot_GoF(data, controls = auto_controls)

plot_GoF(data, controls = pre_hoc_controls)

Normalization

First normalization … based on GoF.

norm_factors <- get_GoF_factors(data)
data$normalised_data <- scale_factor_normalise(data, scaling_factors = norm_factors) 
plot_counts(data, which = "normalised_data")
## Picking joint bandwidth of 0.393

Second normalization … basde on length of genes.

data$normalised_data <- normalise_by_window_width(data, which = "normalised_data")
plot_counts(data, which = "normalised_data")
## Picking joint bandwidth of 0.344

### Save normalized read counts

write.csv(assays(data$normalised_data)[[1]], file="../outputs/rna_seq_normalized_count_in_mRNA.csv")

Estimate BayesFactor and mark significantly different genes for many experiments

(from here, we remove genomic DNA dataset)

diff_expression <- estimate_bayes_factor_multiclass(data, "wt_un", which = "normalised_data", factor = 1.5)
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector
## t is large; approximation invoked.
## Warning: Column `window` joining character vector and factor, coercing into
## character vector

## Warning: Column `window` joining character vector and factor, coercing into
## character vector
diff_expression <- diff_expression[diff_expression$a != "gdna", ]
diff_expression %>% 
    dplyr::filter(is_sig == TRUE) %>%
        dplyr::distinct(a)
##            a
## 1    eds1_a2
## 2    eds1_a4
## 3    eds1_kv
## 4    eds1_mk
## 5      gh_a2
## 6      gh_a4
## 7      gh_kv
## 8      gh_mk
## 9  myc234_a2
## 10 myc234_a4
## 11 myc234_kv
## 12 myc234_mk
## 13   peds_a2
## 14   peds_a4
## 15   peds_kv
## 16   peds_mk
## 17   r1ab_a2
## 18   r1ab_a4
## 19   r1ab_kv
## 20   r1ab_mk
## 21   sid2_a2
## 22   sid2_a4
## 23   sid2_kv
## 24   sid2_mk
## 25 tplr14_a2
## 26 tplr14_a4
## 27 tplr14_kv
## 28 tplr14_mk
## 29     wt_a2
## 30     wt_a4
## 31     wt_kv
## 32     wt_mk

Save differential expression result

write.csv(diff_expression, file = "../outputs/diff_expression_RNA_seq.csv", row.names=FALSE)

UpSetR (remove?)

make_UpSetR <- function(df) {
  log2_fc <- direction <- a <- NULL
  r <- df %>%
    dplyr::mutate(
      direction = ifelse(log2_fold_change > 0, "up", "down"),
      category = paste0(direction, "_", a)
    )
  r <- r %>% split(r$category) %>%
    lapply(function(x)
      as.vector(dplyr::select(x, window)$window))
  return(r)
}


diff_expression %>% 
  dplyr::filter(is_sig == TRUE) %>%
  make_UpSetR() %>%
  fromList() %>%
  upset(
    nsets = 56, 
    nintersects = NA,
    order.by = c("degree", "freq"),
    main.bar.color = "steelblue",
    sets.bar.color = "aquamarine",
    text.scale = 2,
    line.size = 0,
    mb.ratio = c(0.3, 0.7)
    )

Heatmap of differential expression analysis

We remove AT4G28410 in this process.

All genes & all treatments

# make color list for each genes
ID_color_list <- read.csv("../data/ID_color_list.csv")
ID_color_list["color"] <- lapply(ID_color_list["color"], gsub, pattern="blue", replacement=rgb(86/255, 180/255, 233/255))
ID_color_list["color"] <- lapply(ID_color_list["color"], gsub, pattern="red", replacement=rgb(230/255, 159/255, 0))
rownames(ID_color_list) <- ID_color_list$ID

# make heatmap contains 51 genes and all mutants/treatment.
log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
  log2_matrix[log2_matrix == -Inf] <- 0
  log2_matrix<-na.omit(log2_matrix)
  new_color_list <- ID_color_list$color[-41]
  heatmap <- heatmap3::heatmap3(log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)

Save log matrix values

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
write.csv(log2_matrix, file="../outputs/log_matrix_diff_expression.csv")

each 1 treatment vs wt¶

all 51 genes, (vs “eds1”, “gh”, “peds”, “r1ab”)

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
  log2_matrix[log2_matrix == -Inf] <- 0

treatments <- c("eds1", "gh", "peds", "r1ab")

for (treat in treatments) {
    pickup <- c(paste(treat, "_a2", sep=""),paste(treat, "_a4", sep=""),paste(treat, "_kv", sep=""),"wt_a2","wt_a4","wt_kv")
    pickup_log2_matrix <- log2_matrix[,pickup]

    pickup_log2_matrix<-na.omit(pickup_log2_matrix)
    new_color_list <- ID_color_list$color[-41]
    heatmap <- heatmap3::heatmap3(pickup_log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)
}

Pick up specific genes or pick up specific treatment to be clear (vs “myc234”, “sid2”, “tplr14”)

vs myc234

pick up Top 10 genes (myc234_a4 vs wt_a4)

treat <- "myc234"

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
treat_vs_wt_a4 <- sort(log2_matrix[,paste(treat, "_a4", sep="")] / log2_matrix[,"wt_a4"])

pickup <- c(paste(treat, "_a2", sep=""),paste(treat, "_a4", sep=""),paste(treat, "_kv", sep=""),"wt_a2","wt_a4","wt_kv")
pickup_log2_matrix <- log2_matrix[,pickup]
pickup_log2_matrix <- pickup_log2_matrix[names(treat_vs_wt_a4)[c(1:10,42:51)],]

pickup_log2_matrix<-na.omit(pickup_log2_matrix)
new_color_list <- ID_color_list[names(treat_vs_wt_a4)[c(1:10,42:51)], "color"]
heatmap <- heatmap3::heatmap3(pickup_log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)

vs sid2

pick up Top 12 genes (sid2_a4 vs wt_a4)

treat <- "sid2"

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
treat_vs_wt_a4 <- sort(log2_matrix[,paste(treat, "_a4", sep="")] / log2_matrix[,"wt_a4"])

pickup <- c(paste(treat, "_a2", sep=""),paste(treat, "_a4", sep=""),paste(treat, "_kv", sep=""),"wt_a2","wt_a4","wt_kv")
pickup_log2_matrix <- log2_matrix[,pickup]
pickup_log2_matrix <- pickup_log2_matrix[names(treat_vs_wt_a4)[c(1:12,40:51)],]

pickup_log2_matrix<-na.omit(pickup_log2_matrix)
new_color_list <- ID_color_list[names(treat_vs_wt_a4)[c(1:12,40:51)], "color"]
heatmap <- heatmap3::heatmap3(pickup_log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)

vs tplr14 series

pick up only kv, a4

treat <- "tplr14"

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
treat_vs_wt_a4 <- sort(log2_matrix[,paste(treat, "_a4", sep="")] / log2_matrix[,"wt_a4"])

pickup <- c(paste(treat, "_a4", sep=""),paste(treat, "_kv", sep=""),"wt_kv","wt_a4")
pickup_log2_matrix <- log2_matrix[,pickup]
pickup_log2_matrix <- pickup_log2_matrix[names(treat_vs_wt_a4),]

pickup_log2_matrix<-na.omit(pickup_log2_matrix)
new_color_list <- ID_color_list[-41, "color"]
heatmap <- heatmap3::heatmap3(pickup_log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)

pick up only kv, a2

treat <- "tplr14"

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
treat_vs_wt_a4 <- sort(log2_matrix[,paste(treat, "_a2", sep="")] / log2_matrix[,"wt_a2"])

pickup <- c(paste(treat, "_a2", sep=""),paste(treat, "_kv", sep=""),"wt_kv","wt_a2")
pickup_log2_matrix <- log2_matrix[,pickup]
pickup_log2_matrix <- pickup_log2_matrix[names(treat_vs_wt_a4),]

pickup_log2_matrix<-na.omit(pickup_log2_matrix)
new_color_list <- ID_color_list[-41, "color"]
heatmap <- heatmap3::heatmap3(pickup_log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)

pick up only kv, a4 & pick up top 20 genes

treat <- "tplr14"

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
treat_vs_wt_a4 <- sort(log2_matrix[,paste(treat, "_a4", sep="")] / log2_matrix[,"wt_a4"])

pickup <- c(paste(treat, "_a4", sep=""),paste(treat, "_kv", sep=""),"wt_kv","wt_a4")
pickup_log2_matrix <- log2_matrix[,pickup]
pickup_log2_matrix <- pickup_log2_matrix[names(treat_vs_wt_a4)[c(1:20,32:51)],]

pickup_log2_matrix<-na.omit(pickup_log2_matrix)
new_color_list <- ID_color_list[names(treat_vs_wt_a4)[c(1:20,32:51)], "color"]
heatmap <- heatmap3::heatmap3(pickup_log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)

pick up only kv, a2 & pick up top 20 genes

treat <- "tplr14"

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
treat_vs_wt_a4 <- sort(log2_matrix[,paste(treat, "_a2", sep="")] / log2_matrix[,"wt_a2"])

pickup <- c(paste(treat, "_a2", sep=""),paste(treat, "_kv", sep=""),"wt_kv","wt_a2")
pickup_log2_matrix <- log2_matrix[,pickup]
pickup_log2_matrix <- pickup_log2_matrix[names(treat_vs_wt_a4)[c(1:20,32:51)],]

pickup_log2_matrix<-na.omit(pickup_log2_matrix)
new_color_list <- ID_color_list[names(treat_vs_wt_a4)[c(1:20,32:51)], "color"]
heatmap <- heatmap3::heatmap3(pickup_log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)

check similarity between tplr14 and myc234

log2_matrix <- diff_expression %>% 
  reshape2::acast( window ~ a, value.var = "log2_fold_change")
  log2_matrix[log2_matrix == -Inf] <- 0
treat1 <- "tplr14"
treat2 <- "myc234"
pickup <- c(paste(treat1, "_a2", sep=""),paste(treat1, "_a4", sep=""),paste(treat1, "_kv", sep=""),paste(treat2, "_a2", sep=""),paste(treat2, "_a4", sep=""),paste(treat2, "_kv", sep=""),"wt_a2","wt_a4","wt_kv")
pickup_log2_matrix <- log2_matrix[,pickup]

pickup_log2_matrix<-na.omit(pickup_log2_matrix)
new_color_list <- ID_color_list[-41, "color"]
heatmap <- heatmap3::heatmap3(pickup_log2_matrix, cexRow=0.75, margin=c(12, 12), RowAxisColors=1, RowSideColors=new_color_list)